package com.web.common;

import java.io.Serializable;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description:响应结果类,Json格式的数据进行响应
 **/
@Data
@NoArgsConstructor
public class BaseResult<E> implements Serializable {
    //状态码
    private String state = "0";
    //描述信息
    private String message = "";
    //数据：泛型
    private E data;
    //状态码和数据构造
    public BaseResult(String state, E data) {
        this.state = state;
        this.data = data;
    }
    //数据构造
    public BaseResult(E data) {
        this.data = data;
    }

    //数据构造
    public BaseResult(String state,String message) {
        this.state = state;
        this.message = message;
    }

    //异常信息
    public BaseResult(Throwable e) {
        this.message = e.getMessage();
    }
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public E getData() {
		return data;
	}
	public void setData(E data) {
		this.data = data;
	}

}
